package com.lijie.ljblog.controller;

import cn.hutool.core.date.DateUtil;
import com.lijie.ljblog.model.vo.ljpage.LjPageHotWebVO;
import com.lijie.ljblog.service.LjpageWebsitehotService;
import com.lijie.ljblog.service.UtilService;
import com.lijie.ljblog.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author lj
 * @date 2023/5/12 15:20
 * @description
 */
@RestController
@RequestMapping("LjPage/")
public class LjPageController {
    @Resource
    UtilService utilService;

    @Resource
    LjpageWebsitehotService ljpageWebsitehotService;



    @ApiOperation("获取bing每日壁纸图片")
    @GetMapping("BingImg")
    public Result<String> bingDailyImg(){
        String today = DateUtil.today();
        return Result.ok(utilService.bingDailyImg( today));
    }

    @ApiOperation("获取热榜信息")
    @GetMapping("hot/list")
    public Result<List<LjPageHotWebVO>> webSiteList(HttpServletRequest request){
        utilService.webVisitLog(request,"ljPage");
        List<LjPageHotWebVO> listResult = ljpageWebsitehotService.hotList();

        return Result.ok(listResult);
    }

//    @ApiOperation("获取左侧网址推荐")
//    @GetMapping("webSiteList")
//    public Result<String> webSiteList(){
//        ljpageWebsitehotService.webSiteList();
//
//    }

    @ApiOperation("测试获取热门接口")
    @GetMapping("testHotList")
    public Result<String> testHotList(){
        Integer integer = ljpageWebsitehotService.hotDailyUpdate();
        return Result.ok(integer.toString());
    }


}
